package com.cherish.web.user.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cherish.web.menu.entity.Menu;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import java.util.List;

/**
 * Author:MQ
 * Date:2023/12/2317:15
 */
@Data
@TableName("T_SYS_User")
public class User implements Serializable,UserDetails {
    //主键自动增长
    @TableId(value = "FID",type = IdType.AUTO)
    private Long FId;

    //登录名
    @TableField("FUsername")
    private String username;
    //用户名
    @TableField("FLoginName")
    private String loginName;
    //@JsonIgnore
    @TableField("FPassword")
    private String password;

    //创建时间
    @TableField("FCreateTime")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    //岗位名称
    @TableField("FPostName")
    private String postName;

    //由于authorities不是数据库里面的字段，所以要排除他，不然mybatis-plus找不到该字段会报错
    @TableField(exist = false)
    Collection<? extends GrantedAuthority> authorities;

    //帐户是否过期(1 未过期，0已过期)
    @TableField(exist = false)
    private boolean isAccountNonExpired = true;
    //帐户是否被锁定(1 未锁定，0已锁定)
    @TableField(exist = false)
    private boolean isAccountNonLocked = true;
    //密码是否过期(1 未过期，0已过期)
    @TableField(exist = false)
    private boolean isCredentialsNonExpired = true;
    //帐户是否可用(1 可用，0 删除用户)
    @TableField(exist = false)
    private boolean isEnabled = true;

    //是否是管理员 1：是 0 ：不是
    @TableField("FIsAdmin")
    private String isAdmin;
    //用户权限列表,不属于用户表字段，需要排除
    @TableField(exist = false)
    List<Menu> permissionList;
}
